package com.software.modelcenter.repository;

import com.software.modelcenter.entity.ModelInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
/**
 * @Author xiaoliao
 * @Date 2023/5/5 8:38
 */
public interface ModelInfoRepository extends JpaRepository<ModelInfo, String>, JpaSpecificationExecutor<ModelInfo> {

    ModelInfo findByKeyLine(String keyLine);

    @Query(value = "select * from model_info where model_id in(SELECT c.model_id FROM collection c where user_id =?1)",nativeQuery = true)
    List<ModelInfo> findModelByUserId(String userId);

}
